package org.grayrabbit.cms.plugin.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.grayrabbit.cms.plugin.Plugin;
import org.grayrabbit.cms.plugin.elements.ResourceLocation;


/**
 * @author sys53
 * @version 1.0
 * @created 06-一月-2012 17:14:52
 */
public class DownloadableWebResource extends AbstractDownloadableResource {

	public DownloadableWebResource(BaseFileServerServlet servlet,Plugin plugin, ResourceLocation resourceDescriptor, String extraPath) {
		super(servlet, plugin, resourceDescriptor, extraPath);
	}
	/**
	 * 
	 * @param response
	 * @param request
	 * @throws IOException 
	 */
	public void serveResource(HttpServletRequest request,HttpServletResponse response) throws IOException{
		try
	    {
			response.setContentType(getContentType());
			request.getRequestDispatcher(getLocation()).forward(request, response);
	    }
	    catch (ServletException e)
	    {
	      e.printStackTrace();
	      throw new IOException(e.getMessage());
	    }
	}

}